package com.detrum.adapter;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.drawable.Drawable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;

import com.detrum.base.R;
import com.detrum.bean.ShareBean;

import java.util.List;

/**
 * Created by abc on 2018/3/15.
 */

public class ShareGridAdapter extends BaseAdapter {
    private Context context;
    private List<ShareBean> list;
    private LayoutInflater layoutInflater;

    public ShareGridAdapter(Context context, List<ShareBean> list) {
        this.context = context;
        this.list = list;
        layoutInflater = LayoutInflater.from(context);
    }

    @Override
    public int getCount() {
        return list==null?0:list.size();
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ShareHolder2 holder2;
        if(convertView==null){
            convertView = layoutInflater.inflate(R.layout.share_image,parent,false);
            holder2 = new ShareHolder2();
            holder2.icon = convertView.findViewById(R.id.icon);
            convertView.setTag(holder2);
        }else{
            holder2 = (ShareHolder2) convertView.getTag();
        }
        Drawable data = list.get(position).getIcon();
        holder2.icon.setImageDrawable(data);
        return convertView;
    }

    class ShareHolder2{
        ImageView icon;
    }
}
